syntax = "proto3";

import "points.proto";

package qdrant;


service PointsInternal {
  rpc Upsert (UpsertPointsInternal) returns (PointsOperationResponse) {}
  rpc Sync (SyncPointsInternal) returns (PointsOperationResponse) {}
  rpc Delete (DeletePointsInternal) returns (PointsOperationResponse) {}
  rpc UpdateVectors (UpdateVectorsInternal) returns (PointsOperationResponse) {}
  rpc DeleteVectors (DeleteVectorsInternal) returns (PointsOperationResponse) {}
  rpc SetPayload (SetPayloadPointsInternal) returns (PointsOperationResponse) {}
  rpc OverwritePayload (SetPayloadPointsInternal) returns (PointsOperationResponse) {}
  rpc DeletePayload (DeletePayloadPointsInternal) returns (PointsOperationResponse) {}
  rpc ClearPayload (ClearPayloadPointsInternal) returns (PointsOperationResponse) {}
  rpc CreateFieldIndex (CreateFieldIndexCollectionInternal) returns (PointsOperationResponse) {}
  rpc DeleteFieldIndex (DeleteFieldIndexCollectionInternal) returns (PointsOperationResponse) {}
  rpc Search (SearchPointsInternal) returns (SearchResponse) {}
  rpc SearchBatch (SearchBatchPointsInternal) returns (SearchBatchResponse) {}
  rpc CoreSearchBatch (CoreSearchBatchPointsInternal) returns (SearchBatchResponse) {}
  rpc Scroll (ScrollPointsInternal) returns (ScrollResponse) {}
  rpc Count (CountPointsInternal) returns (CountResponse) {}
  rpc Recommend (RecommendPointsInternal) returns (RecommendResponse) {}
  rpc Get (GetPointsInternal) returns (GetResponse) {}
}


message SyncPoints {
  string collection_name = 1; // name of the collection
  optional bool wait = 2; // Wait until the changes have been applied?
  repeated PointStruct points = 3;
  optional PointId from_id = 4; // Start of the sync range
  optional PointId to_id = 5; // End of the sync range
  optional WriteOrdering ordering = 6;
}

message SyncPointsInternal {
  SyncPoints sync_points = 1;
  optional uint32 shard_id = 2;
}

message UpsertPointsInternal {
  UpsertPoints upsert_points = 1;
  optional uint32 shard_id = 2;
}

message DeletePointsInternal {
  DeletePoints delete_points = 1;
  optional uint32 shard_id = 2;
}

message UpdateVectorsInternal {
  UpdatePointVectors update_vectors = 1;
  optional uint32 shard_id = 2;
}

message DeleteVectorsInternal {
  DeletePointVectors delete_vectors = 1;
  optional uint32 shard_id = 2;
}

message SetPayloadPointsInternal {
  SetPayloadPoints set_payload_points = 1;
  optional uint32 shard_id = 2;
}

message DeletePayloadPointsInternal {
  DeletePayloadPoints delete_payload_points = 1;
  optional uint32 shard_id = 2;
}

message ClearPayloadPointsInternal {
  ClearPayloadPoints clear_payload_points = 1;
  optional uint32 shard_id = 2;
}

message CreateFieldIndexCollectionInternal {
  CreateFieldIndexCollection create_field_index_collection = 1;
  optional uint32 shard_id = 2;
}

message DeleteFieldIndexCollectionInternal {
  DeleteFieldIndexCollection delete_field_index_collection = 1;
  optional uint32 shard_id = 2;
}

message SearchPointsInternal {
  SearchPoints search_points = 1;
  optional uint32 shard_id = 2;
}

message SearchBatchPointsInternal {
  string collection_name = 1;
  repeated SearchPoints search_points = 2;
  optional uint32 shard_id = 3;
}

message RecoQuery {
  repeated Vector positives = 1;
  repeated Vector negatives = 2;
}

message QueryEnum {
  oneof query {
    Vector nearest_neighbors = 1; // ANN
    RecoQuery recommend_best_score = 2; // Recommend points with higher similarity to positive examples
  }
}

// This is only used internally, so it makes more sense to add it here rather than in points.proto
message CoreSearchPoints {
  string collection_name = 1;
  QueryEnum query = 2;
  Filter filter = 3;
  uint64 limit = 4; 
  WithPayloadSelector with_payload = 5;
  SearchParams params = 6;
  optional float score_threshold = 7;
  optional uint64 offset = 8;
  optional string vector_name = 9; 
  optional WithVectorsSelector with_vectors = 10; 
  optional ReadConsistency read_consistency = 11; 
}

message CoreSearchBatchPointsInternal {
  string collection_name = 1;
  repeated CoreSearchPoints search_points = 2;
  optional uint32 shard_id = 3;
}

message ScrollPointsInternal {
  ScrollPoints scroll_points = 1;
  optional uint32 shard_id = 2;
}

message RecommendPointsInternal {
  RecommendPoints recommend_points = 1;
  optional uint32 shard_id = 2;
}

message GetPointsInternal {
  GetPoints get_points = 1;
  optional uint32 shard_id = 2;
}

message CountPointsInternal {
  CountPoints count_points = 1;
  optional uint32 shard_id = 2;
}
